<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div style="width: 100px; height: 100px; background: #f00;" onclick="selectFileFunc()"></div>
<script>
    function selectFileFunc (field, accept = 'image/*') {
        console.log('文件上传')
        // let that = this
        // 创建一个虚拟的图片选择元素
        let fileInput = document.createElement('input')
        fileInput.setAttribute('type', 'file')
        fileInput.setAttribute('accept', accept)
        fileInput.click()
        fileInput.addEventListener('change', function (data) {
            let file = data.target.files[0]
            console.log(file)
        })
    }
</script>
</body>
</html>